package org.rency.crawler.domain.http;

import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.http.cookie.Cookie;

/**
 * 名称:FetchHttpResponse
 * 描述:${TODO}
 *
 * @author:rency
 * @version:V1.0.0
 * @JDK 1.8
 * @since 2017/11/22 22:05
 */
public class FetchHttpResponse{

  /**
   * 响应内容
   */
  private byte[]                 content;

  /**
   * 响应状态
   */
  private int                    statusCode;

  /**
   * 字符编码
   */
  private Charset                charset;

  /**
   * HTTP响应头
   */
  private Map<String, String>    headers;

  private List<Cookie>           cookies;

  /**
   * 是否重试
   */
  private boolean                needRetry = false;

  /**
   * 是否需要解析
   */
  private boolean                needParse = false;

  /**
   * 是否文件
   */
  private boolean                isFile = false;

  /**
   * 跳转URL
   */
  private String                 redirectURL;

  public byte[] getContent() {
    return content.clone();
  }

  public void setContent(byte[] content) {
    this.content = content;
  }

  public int getStatusCode() {
    return statusCode;
  }

  public void setStatusCode(int statusCode) {
    this.statusCode = statusCode;
  }

  public Charset getCharset() {
    return charset;
  }

  public void setCharset(Charset charset) {
    this.charset = charset;
  }

  public Map<String, String> getHeaders() {
    return headers;
  }

  public void setHeaders(Map<String, String> headers) {
    this.headers = headers;
  }

  public List<Cookie> getCookies() {
    return cookies;
  }

  public void setCookies(List<Cookie> cookies) {
    this.cookies = cookies;
  }

  public boolean isNeedRetry() {
    return needRetry;
  }

  public void setNeedRetry(boolean needRetry) {
    this.needRetry = needRetry;
  }

  public boolean isNeedParse() {
    return needParse;
  }

  public void setNeedParse(boolean needParse) {
    this.needParse = needParse;
  }

  public boolean isFile() {
    return isFile;
  }

  public void setFile(boolean file) {
    isFile = file;
  }

  public String getRedirectURL() {
    return redirectURL;
  }

  public void setRedirectURL(String redirectURL) {
    this.redirectURL = redirectURL;
  }

  @Override
  public String toString() {
    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
  }
}
